/*
 * @lc app=leetcode.cn id=258 lang=cpp
 *
 * [258] 各位相加
 */

// @lc code=start
class Solution
{
public:
  int addDigits(int num)
  {
    if (num < 10)
      return num;
    int sum = 0;
    for (; num != 0; num /= 10)
      sum += num % 10;
    return addDigits(sum);
  }
};
// @lc code=end
